package at.fhooe.mc;

import static org.easymock.EasyMock.expect;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;
import org.easymock.EasyMock;
import org.easymock.IMocksControl;
import org.junit.Before;
import org.junit.Test;
import sqelevator.IElevator;
import at.fhooe.mc.control.RemoteElevatorAdapter;
import at.fhooe.mc.control.exception.InvalidEnumValueException;
import at.fhooe.mc.control.exception.SameClockTickException;
import at.fhooe.mc.data.ControlMode;
import at.fhooe.mc.data.DirectionType;
import at.fhooe.mc.data.DoorState;
import at.fhooe.mc.data.ElevatorData;
import at.fhooe.mc.data.FloorData;
import at.fhooe.mc.data.SystemData;
import at.fhooe.mc.data.control.ElevatorControlData;

public class RemoteElevatorAdapterTest
{

	private IElevator mock;
	private IMocksControl ctrl;
	private RemoteElevatorAdapter adapter;

	private SystemData defaultData;
	private ElevatorData defaultElevator;
	private ElevatorControlData defaultControlElevator;

	@Before
	public void setUp()
	{
		ctrl = EasyMock.createStrictControl();
		mock = ctrl.createMock(IElevator.class);

		adapter = new RemoteElevatorAdapter();
		adapter.setController(mock);

		defaultData = new SystemData();
		defaultData.setClockTick(1000L);
		defaultData.setFloorHeight(20);

		FloorData f = new FloorData();
		f.setFloorIndex(0);
		f.setFloorButtonDown(false);
		f.setFloorButtonUp(true);
		defaultData.getFloors().add(f);

		f = new FloorData();
		f.setFloorIndex(1);
		f.setFloorButtonDown(true);
		f.setFloorButtonUp(false);
		defaultData.getFloors().add(f);

		f = new FloorData();
		f.setFloorIndex(2);
		f.setFloorButtonDown(true);
		f.setFloorButtonUp(true);
		defaultData.getFloors().add(f);

		f = new FloorData();
		f.setFloorIndex(3);
		f.setFloorButtonDown(false);
		f.setFloorButtonUp(false);
		defaultData.getFloors().add(f);

		defaultElevator = new ElevatorData(4, ControlMode.AUTOMATIC);
		defaultElevator.setElevatorIndex(0);
		defaultElevator.setElevatorFloor(2);
		defaultElevator.setElevatorPosition(10);
		defaultElevator.setCurrentTarget(3);
		defaultElevator.setCommittedDirection(DirectionType.UP);
		defaultElevator.setElevatorDoorStatus(DoorState.OPEN);
		defaultElevator.setElevatorSpeed(23);
		defaultElevator.setElevatorAccel(12);
		defaultElevator.setElevatorCapacity(200);
		defaultElevator.setElevatorWeight(100);

		defaultElevator.getElevatorButton()[0] = true;
		defaultElevator.getElevatorButton()[1] = false;
		defaultElevator.getElevatorButton()[2] = true;
		defaultElevator.getElevatorButton()[3] = false;

		defaultElevator.getServicesFloors()[0] = false;
		defaultElevator.getServicesFloors()[1] = false;
		defaultElevator.getServicesFloors()[2] = true;
		defaultElevator.getServicesFloors()[3] = true;

		defaultData.getElevators().add(defaultElevator);

		defaultControlElevator = new ElevatorControlData();
		defaultControlElevator.setMode(ControlMode.AUTOMATIC);

		ElevatorData e = new ElevatorData(4, ControlMode.MANUAL);
		e.setElevatorIndex(1);
		e.setElevatorFloor(1);
		e.setElevatorPosition(2);
		e.setCurrentTarget(0);
		e.setCommittedDirection(DirectionType.DOWN);
		e.setElevatorDoorStatus(DoorState.OPENING);
		e.setElevatorSpeed(0);
		e.setElevatorAccel(-1);
		e.setElevatorCapacity(220);
		e.setElevatorWeight(90);

		e.getElevatorButton()[0] = false;
		e.getElevatorButton()[1] = true;
		e.getElevatorButton()[2] = false;
		e.getElevatorButton()[3] = true;

		e.getServicesFloors()[0] = true;
		e.getServicesFloors()[1] = true;
		e.getServicesFloors()[2] = false;
		e.getServicesFloors()[3] = false;

		defaultData.getElevators().add(e);
	}

	private void expectMethodsForDefaultData(long click) throws RemoteException
	{
		expect(mock.getClockTick()).andReturn(click);
		expect(mock.getElevatorNum()).andReturn(3);
		expect(mock.getFloorNum()).andReturn(7);
		expect(mock.getFloorHeight()).andReturn(4);

		expect(mock.getFloorButtonUp(0)).andReturn(true);
		expect(mock.getFloorButtonDown(0)).andReturn(false);
		expect(mock.getFloorButtonUp(1)).andReturn(false);
		expect(mock.getFloorButtonDown(1)).andReturn(true);
		expect(mock.getFloorButtonUp(2)).andReturn(false);
		expect(mock.getFloorButtonDown(2)).andReturn(false);
		expect(mock.getFloorButtonUp(3)).andReturn(false);
		expect(mock.getFloorButtonDown(3)).andReturn(true);
		expect(mock.getFloorButtonUp(4)).andReturn(true);
		expect(mock.getFloorButtonDown(4)).andReturn(true);
		expect(mock.getFloorButtonUp(5)).andReturn(false);
		expect(mock.getFloorButtonDown(5)).andReturn(true);
		expect(mock.getFloorButtonUp(6)).andReturn(true);
		expect(mock.getFloorButtonDown(6)).andReturn(true);

		expect(mock.getElevatorFloor(0)).andReturn(6);
		expect(mock.getElevatorPosition(0)).andReturn(1);
		expect(mock.getTarget(0)).andReturn(2);
		expect(mock.getCommittedDirection(0)).andReturn(
			IElevator.ELEVATOR_DIRECTION_DOWN);
		expect(mock.getElevatorDoorStatus(0)).andReturn(
			IElevator.ELEVATOR_DOORS_CLOSED);
		expect(mock.getElevatorSpeed(0)).andReturn(2);
		expect(mock.getElevatorAccel(0)).andReturn(0);
		expect(mock.getElevatorCapacity(0)).andReturn(10);
		expect(mock.getElevatorWeight(0)).andReturn(5);

		expect(mock.getElevatorButton(0, 0)).andReturn(false);
		expect(mock.getElevatorButton(0, 1)).andReturn(true);
		expect(mock.getElevatorButton(0, 2)).andReturn(false);
		expect(mock.getElevatorButton(0, 3)).andReturn(true);
		expect(mock.getElevatorButton(0, 4)).andReturn(false);
		expect(mock.getElevatorButton(0, 5)).andReturn(true);
		expect(mock.getElevatorButton(0, 6)).andReturn(false);

		expect(mock.getServicesFloors(0, 0)).andReturn(false);
		expect(mock.getServicesFloors(0, 1)).andReturn(false);
		expect(mock.getServicesFloors(0, 2)).andReturn(true);
		expect(mock.getServicesFloors(0, 3)).andReturn(true);
		expect(mock.getServicesFloors(0, 4)).andReturn(false);
		expect(mock.getServicesFloors(0, 5)).andReturn(true);
		expect(mock.getServicesFloors(0, 6)).andReturn(false);

		expect(mock.getElevatorFloor(1)).andReturn(1);
		expect(mock.getElevatorPosition(1)).andReturn(2);
		expect(mock.getTarget(1)).andReturn(3);
		expect(mock.getCommittedDirection(1)).andReturn(
			IElevator.ELEVATOR_DIRECTION_UNCOMMITTED);
		expect(mock.getElevatorDoorStatus(1)).andReturn(
			IElevator.ELEVATOR_DOORS_CLOSING);
		expect(mock.getElevatorSpeed(1)).andReturn(4);
		expect(mock.getElevatorAccel(1)).andReturn(-1);
		expect(mock.getElevatorCapacity(1)).andReturn(30);
		expect(mock.getElevatorWeight(1)).andReturn(30);

		expect(mock.getElevatorButton(1, 0)).andReturn(true);
		expect(mock.getElevatorButton(1, 1)).andReturn(true);
		expect(mock.getElevatorButton(1, 2)).andReturn(true);
		expect(mock.getElevatorButton(1, 3)).andReturn(false);
		expect(mock.getElevatorButton(1, 4)).andReturn(false);
		expect(mock.getElevatorButton(1, 5)).andReturn(false);
		expect(mock.getElevatorButton(1, 6)).andReturn(false);

		expect(mock.getServicesFloors(1, 0)).andReturn(true);
		expect(mock.getServicesFloors(1, 1)).andReturn(false);
		expect(mock.getServicesFloors(1, 2)).andReturn(true);
		expect(mock.getServicesFloors(1, 3)).andReturn(false);
		expect(mock.getServicesFloors(1, 4)).andReturn(true);
		expect(mock.getServicesFloors(1, 5)).andReturn(false);
		expect(mock.getServicesFloors(1, 6)).andReturn(true);

		expect(mock.getElevatorFloor(2)).andReturn(5);
		expect(mock.getElevatorPosition(2)).andReturn(4);
		expect(mock.getTarget(2)).andReturn(0);
		expect(mock.getCommittedDirection(2)).andReturn(
			IElevator.ELEVATOR_DIRECTION_UNCOMMITTED);
		expect(mock.getElevatorDoorStatus(2)).andReturn(
			IElevator.ELEVATOR_DOORS_CLOSING);
		expect(mock.getElevatorSpeed(2)).andReturn(8);
		expect(mock.getElevatorAccel(2)).andReturn(9);
		expect(mock.getElevatorCapacity(2)).andReturn(12);
		expect(mock.getElevatorWeight(2)).andReturn(11);

		expect(mock.getElevatorButton(2, 0)).andReturn(true);
		expect(mock.getElevatorButton(2, 1)).andReturn(true);
		expect(mock.getElevatorButton(2, 2)).andReturn(true);
		expect(mock.getElevatorButton(2, 3)).andReturn(false);
		expect(mock.getElevatorButton(2, 4)).andReturn(false);
		expect(mock.getElevatorButton(2, 5)).andReturn(true);
		expect(mock.getElevatorButton(2, 6)).andReturn(false);

		expect(mock.getServicesFloors(2, 0)).andReturn(true);
		expect(mock.getServicesFloors(2, 1)).andReturn(false);
		expect(mock.getServicesFloors(2, 2)).andReturn(true);
		expect(mock.getServicesFloors(2, 3)).andReturn(false);
		expect(mock.getServicesFloors(2, 4)).andReturn(false);
		expect(mock.getServicesFloors(2, 5)).andReturn(false);
		expect(mock.getServicesFloors(2, 6)).andReturn(true);
	}

	private void expectMethodsInitial(long click) throws RemoteException
	{
		expect(mock.getClockTick()).andReturn(click);
		expect(mock.getElevatorNum()).andReturn(3);
		expect(mock.getFloorNum()).andReturn(7);
		expect(mock.getFloorHeight()).andReturn(4);

		expect(mock.getFloorButtonUp(0)).andReturn(true);
		expect(mock.getFloorButtonDown(0)).andReturn(false);
		expect(mock.getFloorButtonUp(1)).andReturn(false);
		expect(mock.getFloorButtonDown(1)).andReturn(true);
		expect(mock.getFloorButtonUp(2)).andReturn(false);
		expect(mock.getFloorButtonDown(2)).andReturn(false);
		expect(mock.getFloorButtonUp(3)).andReturn(false);
		expect(mock.getFloorButtonDown(3)).andReturn(true);
		expect(mock.getFloorButtonUp(4)).andReturn(true);
		expect(mock.getFloorButtonDown(4)).andReturn(true);
		expect(mock.getFloorButtonUp(5)).andReturn(false);
		expect(mock.getFloorButtonDown(5)).andReturn(true);
		expect(mock.getFloorButtonUp(6)).andReturn(true);
		expect(mock.getFloorButtonDown(6)).andReturn(true);

		expect(mock.getElevatorFloor(0)).andReturn(6);
		expect(mock.getElevatorPosition(0)).andReturn(1);
		expect(mock.getTarget(0)).andReturn(2);
		expect(mock.getCommittedDirection(0)).andReturn(
			IElevator.ELEVATOR_DIRECTION_DOWN);
		expect(mock.getElevatorDoorStatus(0)).andReturn(
			IElevator.ELEVATOR_DOORS_CLOSED);
		expect(mock.getElevatorSpeed(0)).andReturn(2);
		expect(mock.getElevatorAccel(0)).andReturn(0);
		expect(mock.getElevatorCapacity(0)).andReturn(10);
		expect(mock.getElevatorWeight(0)).andReturn(5);

		expect(mock.getElevatorButton(0, 0)).andReturn(false);
		expect(mock.getElevatorButton(0, 1)).andReturn(true);
		expect(mock.getElevatorButton(0, 2)).andReturn(false);
		expect(mock.getElevatorButton(0, 3)).andReturn(true);
		expect(mock.getElevatorButton(0, 4)).andReturn(false);
		expect(mock.getElevatorButton(0, 5)).andReturn(true);
		expect(mock.getElevatorButton(0, 6)).andReturn(false);

		expect(mock.getServicesFloors(0, 0)).andReturn(false);
		expect(mock.getServicesFloors(0, 1)).andReturn(false);
		expect(mock.getServicesFloors(0, 2)).andReturn(true);
		expect(mock.getServicesFloors(0, 3)).andReturn(true);
		expect(mock.getServicesFloors(0, 4)).andReturn(false);
		expect(mock.getServicesFloors(0, 5)).andReturn(true);
		expect(mock.getServicesFloors(0, 6)).andReturn(false);

		expect(mock.getElevatorFloor(1)).andReturn(1);
		expect(mock.getElevatorPosition(1)).andReturn(2);
		expect(mock.getTarget(1)).andReturn(3);
		expect(mock.getCommittedDirection(1)).andReturn(
			IElevator.ELEVATOR_DIRECTION_UNCOMMITTED);
		expect(mock.getElevatorDoorStatus(1)).andReturn(
			IElevator.ELEVATOR_DOORS_CLOSING);
		expect(mock.getElevatorSpeed(1)).andReturn(4);
		expect(mock.getElevatorAccel(1)).andReturn(-1);
		expect(mock.getElevatorCapacity(1)).andReturn(30);
		expect(mock.getElevatorWeight(1)).andReturn(30);

		expect(mock.getElevatorButton(1, 0)).andReturn(true);
		expect(mock.getElevatorButton(1, 1)).andReturn(true);
		expect(mock.getElevatorButton(1, 2)).andReturn(true);
		expect(mock.getElevatorButton(1, 3)).andReturn(false);
		expect(mock.getElevatorButton(1, 4)).andReturn(false);
		expect(mock.getElevatorButton(1, 5)).andReturn(false);
		expect(mock.getElevatorButton(1, 6)).andReturn(false);

		expect(mock.getServicesFloors(1, 0)).andReturn(true);
		expect(mock.getServicesFloors(1, 1)).andReturn(false);
		expect(mock.getServicesFloors(1, 2)).andReturn(true);
		expect(mock.getServicesFloors(1, 3)).andReturn(false);
		expect(mock.getServicesFloors(1, 4)).andReturn(true);
		expect(mock.getServicesFloors(1, 5)).andReturn(false);
		expect(mock.getServicesFloors(1, 6)).andReturn(true);

		expect(mock.getElevatorFloor(2)).andReturn(5);
		expect(mock.getElevatorPosition(2)).andReturn(4);
		expect(mock.getTarget(2)).andReturn(0);
		expect(mock.getCommittedDirection(2)).andReturn(
			IElevator.ELEVATOR_DIRECTION_UNCOMMITTED);
		expect(mock.getElevatorDoorStatus(2)).andReturn(
			IElevator.ELEVATOR_DOORS_CLOSING);
		expect(mock.getElevatorSpeed(2)).andReturn(8);
		expect(mock.getElevatorAccel(2)).andReturn(9);
		expect(mock.getElevatorCapacity(2)).andReturn(12);
		expect(mock.getElevatorWeight(2)).andReturn(11);

		expect(mock.getElevatorButton(2, 0)).andReturn(true);
		expect(mock.getElevatorButton(2, 1)).andReturn(true);
		expect(mock.getElevatorButton(2, 2)).andReturn(true);
		expect(mock.getElevatorButton(2, 3)).andReturn(false);
		expect(mock.getElevatorButton(2, 4)).andReturn(false);
		expect(mock.getElevatorButton(2, 5)).andReturn(true);
		expect(mock.getElevatorButton(2, 6)).andReturn(false);

		expect(mock.getServicesFloors(2, 0)).andReturn(true);
		expect(mock.getServicesFloors(2, 1)).andReturn(false);
		expect(mock.getServicesFloors(2, 2)).andReturn(true);
		expect(mock.getServicesFloors(2, 3)).andReturn(false);
		expect(mock.getServicesFloors(2, 4)).andReturn(false);
		expect(mock.getServicesFloors(2, 5)).andReturn(false);
		expect(mock.getServicesFloors(2, 6)).andReturn(true);
	}

	private void assertInitial(SystemData systemData, long click)
	{
		assertEquals(click, systemData.getClockTick());
		assertEquals(3, systemData.getElevators().size());
		assertEquals(7, systemData.getFloors().size());
		assertEquals(4, systemData.getFloorHeight());

		ArrayList<FloorData> floors = systemData.getFloors();

		assertEquals(true, floors.get(0).isFloorButtonUp());
		assertEquals(false, floors.get(1).isFloorButtonUp());
		assertEquals(false, floors.get(2).isFloorButtonUp());
		assertEquals(false, floors.get(3).isFloorButtonUp());
		assertEquals(true, floors.get(4).isFloorButtonUp());
		assertEquals(false, floors.get(5).isFloorButtonUp());
		assertEquals(true, floors.get(6).isFloorButtonUp());

		assertEquals(false, floors.get(0).isFloorButtonDown());
		assertEquals(true, floors.get(1).isFloorButtonDown());
		assertEquals(false, floors.get(2).isFloorButtonDown());
		assertEquals(true, floors.get(3).isFloorButtonDown());
		assertEquals(true, floors.get(4).isFloorButtonDown());
		assertEquals(true, floors.get(5).isFloorButtonDown());
		assertEquals(true, floors.get(6).isFloorButtonDown());

		assertEquals(0, floors.get(0).getFloorIndex());
		assertEquals(1, floors.get(1).getFloorIndex());
		assertEquals(2, floors.get(2).getFloorIndex());
		assertEquals(3, floors.get(3).getFloorIndex());
		assertEquals(4, floors.get(4).getFloorIndex());
		assertEquals(5, floors.get(5).getFloorIndex());
		assertEquals(6, floors.get(6).getFloorIndex());

		ArrayList<ElevatorData> elevators = systemData.getElevators();

		assertEquals(0, elevators.get(0).getElevatorIndex());
		assertEquals(ControlMode.AUTOMATIC, elevators.get(0).getMode());
		assertEquals(6, elevators.get(0).getElevatorFloor());
		assertEquals(1, elevators.get(0).getElevatorPosition());
		assertEquals(2, elevators.get(0).getCurrentTarget());
		assertEquals(DirectionType.DOWN,
			elevators.get(0).getCommittedDirection());
		assertEquals(DoorState.CLOSED, elevators.get(0).getElevatorDoorStatus());
		assertEquals(2, elevators.get(0).getElevatorSpeed());
		assertEquals(0, elevators.get(0).getElevatorAccel());
		assertEquals(10, elevators.get(0).getElevatorCapacity());
		assertEquals(5, elevators.get(0).getElevatorWeight());

		assertEquals(7, elevators.get(0).getElevatorButton().length);
		assertEquals(false, elevators.get(0).getElevatorButton()[0]);
		assertEquals(true, elevators.get(0).getElevatorButton()[1]);
		assertEquals(false, elevators.get(0).getElevatorButton()[2]);
		assertEquals(true, elevators.get(0).getElevatorButton()[3]);
		assertEquals(false, elevators.get(0).getElevatorButton()[4]);
		assertEquals(true, elevators.get(0).getElevatorButton()[5]);
		assertEquals(false, elevators.get(0).getElevatorButton()[6]);

		assertEquals(7, elevators.get(0).getServicesFloors().length);
		assertEquals(false, elevators.get(0).getServicesFloors()[0]);
		assertEquals(false, elevators.get(0).getServicesFloors()[1]);
		assertEquals(true, elevators.get(0).getServicesFloors()[2]);
		assertEquals(true, elevators.get(0).getServicesFloors()[3]);
		assertEquals(false, elevators.get(0).getServicesFloors()[4]);
		assertEquals(true, elevators.get(0).getServicesFloors()[5]);
		assertEquals(false, elevators.get(0).getServicesFloors()[6]);

		assertEquals(1, elevators.get(1).getElevatorIndex());
		assertEquals(ControlMode.AUTOMATIC, elevators.get(1).getMode());
		assertEquals(1, elevators.get(1).getElevatorFloor());
		assertEquals(2, elevators.get(1).getElevatorPosition());
		assertEquals(3, elevators.get(1).getCurrentTarget());
		assertEquals(DirectionType.UNCOMMITTED,
			elevators.get(1).getCommittedDirection());
		assertEquals(DoorState.CLOSING,
			elevators.get(1).getElevatorDoorStatus());
		assertEquals(4, elevators.get(1).getElevatorSpeed());
		assertEquals(-1, elevators.get(1).getElevatorAccel());
		assertEquals(30, elevators.get(1).getElevatorCapacity());
		assertEquals(30, elevators.get(1).getElevatorWeight());

		assertEquals(7, elevators.get(1).getElevatorButton().length);
		assertEquals(true, elevators.get(1).getElevatorButton()[0]);
		assertEquals(true, elevators.get(1).getElevatorButton()[1]);
		assertEquals(true, elevators.get(1).getElevatorButton()[2]);
		assertEquals(false, elevators.get(1).getElevatorButton()[3]);
		assertEquals(false, elevators.get(1).getElevatorButton()[4]);
		assertEquals(false, elevators.get(1).getElevatorButton()[5]);
		assertEquals(false, elevators.get(1).getElevatorButton()[6]);

		assertEquals(7, elevators.get(1).getServicesFloors().length);
		assertEquals(true, elevators.get(1).getServicesFloors()[0]);
		assertEquals(false, elevators.get(1).getServicesFloors()[1]);
		assertEquals(true, elevators.get(1).getServicesFloors()[2]);
		assertEquals(false, elevators.get(1).getServicesFloors()[3]);
		assertEquals(true, elevators.get(1).getServicesFloors()[4]);
		assertEquals(false, elevators.get(1).getServicesFloors()[5]);
		assertEquals(true, elevators.get(1).getServicesFloors()[6]);

		assertEquals(2, elevators.get(2).getElevatorIndex());
		assertEquals(ControlMode.AUTOMATIC, elevators.get(1).getMode());
		assertEquals(5, elevators.get(2).getElevatorFloor());
		assertEquals(4, elevators.get(2).getElevatorPosition());
		assertEquals(0, elevators.get(2).getCurrentTarget());
		assertEquals(DirectionType.UNCOMMITTED,
			elevators.get(2).getCommittedDirection());
		assertEquals(DoorState.CLOSING,
			elevators.get(2).getElevatorDoorStatus());
		assertEquals(8, elevators.get(2).getElevatorSpeed());
		assertEquals(9, elevators.get(2).getElevatorAccel());
		assertEquals(12, elevators.get(2).getElevatorCapacity());
		assertEquals(11, elevators.get(2).getElevatorWeight());

		assertEquals(7, elevators.get(2).getElevatorButton().length);
		assertEquals(true, elevators.get(2).getElevatorButton()[0]);
		assertEquals(true, elevators.get(2).getElevatorButton()[1]);
		assertEquals(true, elevators.get(2).getElevatorButton()[2]);
		assertEquals(false, elevators.get(2).getElevatorButton()[3]);
		assertEquals(false, elevators.get(2).getElevatorButton()[4]);
		assertEquals(true, elevators.get(2).getElevatorButton()[5]);
		assertEquals(false, elevators.get(2).getElevatorButton()[6]);

		assertEquals(7, elevators.get(2).getServicesFloors().length);
		assertEquals(true, elevators.get(2).getServicesFloors()[0]);
		assertEquals(false, elevators.get(2).getServicesFloors()[1]);
		assertEquals(true, elevators.get(2).getServicesFloors()[2]);
		assertEquals(false, elevators.get(2).getServicesFloors()[3]);
		assertEquals(false, elevators.get(2).getServicesFloors()[4]);
		assertEquals(false, elevators.get(2).getServicesFloors()[5]);
		assertEquals(true, elevators.get(2).getServicesFloors()[6]);
	}

	@Test
	public void testParseDataInitial() throws RemoteException,
		SameClockTickException, InvalidEnumValueException
	{
		expectMethodsInitial(800L);

		expect(mock.getClockTick()).andReturn(800L);

		ctrl.replay();

		assertInitial(adapter.parseData(null, null), 800L);

		ctrl.verify();
	}

	@Test
	public void testParseDataLoop() throws RemoteException,
		SameClockTickException, InvalidEnumValueException
	{
		SystemData data = new SystemData();

		ElevatorData e = new ElevatorData(5, null);
		data.getElevators().add(e);

		e = new ElevatorData(5, null);
		data.getElevators().add(e);

		e = new ElevatorData(5, null);
		data.getElevators().add(e);

		List<ElevatorControlData> controlList = new ArrayList<ElevatorControlData>();

		ElevatorControlData controlData = new ElevatorControlData();
		controlData.setMode(ControlMode.AUTOMATIC);
		controlList.add(controlData);

		controlData = new ElevatorControlData();
		controlData.setMode(ControlMode.MANUAL);
		controlList.add(controlData);

		controlData = new ElevatorControlData();
		controlData.setMode(ControlMode.MANUAL);
		controlList.add(controlData);

		expect(mock.getClockTick()).andReturn(1000L);
		expect(mock.getElevatorNum()).andReturn(3);
		expect(mock.getFloorNum()).andReturn(5);
		expect(mock.getFloorHeight()).andReturn(2);

		expect(mock.getFloorButtonUp(0)).andReturn(true);
		expect(mock.getFloorButtonDown(0)).andReturn(false);
		expect(mock.getFloorButtonUp(1)).andReturn(false);
		expect(mock.getFloorButtonDown(1)).andReturn(true);
		expect(mock.getFloorButtonUp(2)).andReturn(false);
		expect(mock.getFloorButtonDown(2)).andReturn(false);
		expect(mock.getFloorButtonUp(3)).andReturn(false);
		expect(mock.getFloorButtonDown(3)).andReturn(true);
		expect(mock.getFloorButtonUp(4)).andReturn(true);
		expect(mock.getFloorButtonDown(4)).andReturn(true);

		// elevator number 1

		expect(mock.getElevatorFloor(0)).andReturn(2);
		expect(mock.getElevatorPosition(0)).andReturn(12);
		expect(mock.getTarget(0)).andReturn(3);
		expect(mock.getCommittedDirection(0)).andReturn(
			IElevator.ELEVATOR_DIRECTION_UNCOMMITTED);
		expect(mock.getElevatorDoorStatus(0)).andReturn(
			IElevator.ELEVATOR_DOORS_CLOSING);
		expect(mock.getElevatorSpeed(0)).andReturn(24);
		expect(mock.getElevatorAccel(0)).andReturn(-2);
		expect(mock.getElevatorCapacity(0)).andReturn(100);
		expect(mock.getElevatorWeight(0)).andReturn(50);

		expect(mock.getElevatorButton(0, 0)).andReturn(false);
		expect(mock.getElevatorButton(0, 1)).andReturn(true);
		expect(mock.getElevatorButton(0, 2)).andReturn(false);
		expect(mock.getElevatorButton(0, 3)).andReturn(true);
		expect(mock.getElevatorButton(0, 4)).andReturn(false);

		expect(mock.getServicesFloors(0, 0)).andReturn(false);
		expect(mock.getServicesFloors(0, 1)).andReturn(false);
		expect(mock.getServicesFloors(0, 2)).andReturn(true);
		expect(mock.getServicesFloors(0, 3)).andReturn(true);
		expect(mock.getServicesFloors(0, 4)).andReturn(false);

		//elevator number 2

		expect(mock.getElevatorFloor(1)).andReturn(4);
		expect(mock.getElevatorPosition(1)).andReturn(20);
		expect(mock.getTarget(1)).andReturn(0);
		expect(mock.getCommittedDirection(1)).andReturn(
			IElevator.ELEVATOR_DIRECTION_DOWN);
		expect(mock.getElevatorDoorStatus(1)).andReturn(
			IElevator.ELEVATOR_DOORS_OPENING);
		expect(mock.getElevatorSpeed(1)).andReturn(-3);
		expect(mock.getElevatorAccel(1)).andReturn(5);
		expect(mock.getElevatorCapacity(1)).andReturn(200);
		expect(mock.getElevatorWeight(1)).andReturn(100);

		expect(mock.getElevatorButton(1, 0)).andReturn(true);
		expect(mock.getElevatorButton(1, 1)).andReturn(false);
		expect(mock.getElevatorButton(1, 2)).andReturn(true);
		expect(mock.getElevatorButton(1, 3)).andReturn(true);
		expect(mock.getElevatorButton(1, 4)).andReturn(false);

		expect(mock.getServicesFloors(1, 0)).andReturn(true);
		expect(mock.getServicesFloors(1, 1)).andReturn(true);
		expect(mock.getServicesFloors(1, 2)).andReturn(true);
		expect(mock.getServicesFloors(1, 3)).andReturn(false);
		expect(mock.getServicesFloors(1, 4)).andReturn(false);

		//elevator number 3

		expect(mock.getElevatorFloor(2)).andReturn(1);
		expect(mock.getElevatorPosition(2)).andReturn(1);
		expect(mock.getTarget(2)).andReturn(0);
		expect(mock.getCommittedDirection(2)).andReturn(
			IElevator.ELEVATOR_DIRECTION_DOWN);
		expect(mock.getElevatorDoorStatus(2)).andReturn(
			IElevator.ELEVATOR_DOORS_OPEN);
		expect(mock.getElevatorSpeed(2)).andReturn(0);
		expect(mock.getElevatorAccel(2)).andReturn(5);
		expect(mock.getElevatorCapacity(2)).andReturn(4);
		expect(mock.getElevatorWeight(2)).andReturn(3);

		expect(mock.getElevatorButton(2, 0)).andReturn(true);
		expect(mock.getElevatorButton(2, 1)).andReturn(false);
		expect(mock.getElevatorButton(2, 2)).andReturn(true);
		expect(mock.getElevatorButton(2, 3)).andReturn(true);
		expect(mock.getElevatorButton(2, 4)).andReturn(false);

		expect(mock.getServicesFloors(2, 0)).andReturn(true);
		expect(mock.getServicesFloors(2, 1)).andReturn(true);
		expect(mock.getServicesFloors(2, 2)).andReturn(true);
		expect(mock.getServicesFloors(2, 3)).andReturn(false);
		expect(mock.getServicesFloors(2, 4)).andReturn(false);

		expect(mock.getClockTick()).andReturn(1000L);

		ctrl.replay();

		SystemData systemData = adapter.parseData(data, controlList);

		assertEquals(1000L, systemData.getClockTick());
		assertEquals(3, systemData.getElevators().size());
		assertEquals(5, systemData.getFloors().size());
		assertEquals(2, systemData.getFloorHeight());

		ArrayList<FloorData> floors = systemData.getFloors();

		assertEquals(true, floors.get(0).isFloorButtonUp());
		assertEquals(false, floors.get(1).isFloorButtonUp());
		assertEquals(false, floors.get(2).isFloorButtonUp());
		assertEquals(false, floors.get(3).isFloorButtonUp());
		assertEquals(true, floors.get(4).isFloorButtonUp());

		assertEquals(false, floors.get(0).isFloorButtonDown());
		assertEquals(true, floors.get(1).isFloorButtonDown());
		assertEquals(false, floors.get(2).isFloorButtonDown());
		assertEquals(true, floors.get(3).isFloorButtonDown());
		assertEquals(true, floors.get(4).isFloorButtonDown());

		assertEquals(0, floors.get(0).getFloorIndex());
		assertEquals(1, floors.get(1).getFloorIndex());
		assertEquals(2, floors.get(2).getFloorIndex());
		assertEquals(3, floors.get(3).getFloorIndex());
		assertEquals(4, floors.get(4).getFloorIndex());

		ArrayList<ElevatorData> elevators = systemData.getElevators();

		//elevator number 1

		assertEquals(0, elevators.get(0).getElevatorIndex());
		assertEquals(ControlMode.AUTOMATIC, elevators.get(0).getMode());
		assertEquals(2, elevators.get(0).getElevatorFloor());
		assertEquals(12, elevators.get(0).getElevatorPosition());
		assertEquals(3, elevators.get(0).getCurrentTarget());
		assertEquals(DirectionType.UNCOMMITTED,
			elevators.get(0).getCommittedDirection());
		assertEquals(DoorState.CLOSING,
			elevators.get(0).getElevatorDoorStatus());
		assertEquals(24, elevators.get(0).getElevatorSpeed());
		assertEquals(-2, elevators.get(0).getElevatorAccel());
		assertEquals(100, elevators.get(0).getElevatorCapacity());
		assertEquals(50, elevators.get(0).getElevatorWeight());

		assertEquals(5, elevators.get(0).getElevatorButton().length);
		assertEquals(false, elevators.get(0).getElevatorButton()[0]);
		assertEquals(true, elevators.get(0).getElevatorButton()[1]);
		assertEquals(false, elevators.get(0).getElevatorButton()[2]);
		assertEquals(true, elevators.get(0).getElevatorButton()[3]);
		assertEquals(false, elevators.get(0).getElevatorButton()[4]);

		assertEquals(5, elevators.get(0).getServicesFloors().length);
		assertEquals(false, elevators.get(0).getServicesFloors()[0]);
		assertEquals(false, elevators.get(0).getServicesFloors()[1]);
		assertEquals(true, elevators.get(0).getServicesFloors()[2]);
		assertEquals(true, elevators.get(0).getServicesFloors()[3]);
		assertEquals(false, elevators.get(0).getServicesFloors()[4]);

		//elevator number 2

		assertEquals(1, elevators.get(1).getElevatorIndex());
		assertEquals(ControlMode.MANUAL, elevators.get(1).getMode());
		assertEquals(4, elevators.get(1).getElevatorFloor());
		assertEquals(20, elevators.get(1).getElevatorPosition());
		assertEquals(0, elevators.get(1).getCurrentTarget());
		assertEquals(DirectionType.DOWN,
			elevators.get(1).getCommittedDirection());
		assertEquals(DoorState.OPENING, elevators.get(1).getElevatorDoorStatus());
		assertEquals(-3, elevators.get(1).getElevatorSpeed());
		assertEquals(5, elevators.get(1).getElevatorAccel());
		assertEquals(200, elevators.get(1).getElevatorCapacity());
		assertEquals(100, elevators.get(1).getElevatorWeight());

		assertEquals(5, elevators.get(1).getElevatorButton().length);
		assertEquals(true, elevators.get(1).getElevatorButton()[0]);
		assertEquals(false, elevators.get(1).getElevatorButton()[1]);
		assertEquals(true, elevators.get(1).getElevatorButton()[2]);
		assertEquals(true, elevators.get(1).getElevatorButton()[3]);
		assertEquals(false, elevators.get(1).getElevatorButton()[4]);

		assertEquals(5, elevators.get(1).getServicesFloors().length);
		assertEquals(true, elevators.get(1).getServicesFloors()[0]);
		assertEquals(true, elevators.get(1).getServicesFloors()[1]);
		assertEquals(true, elevators.get(1).getServicesFloors()[2]);
		assertEquals(false, elevators.get(1).getServicesFloors()[3]);
		assertEquals(false, elevators.get(1).getServicesFloors()[4]);

		//elevator number 3

		assertEquals(2, elevators.get(2).getElevatorIndex());
		assertEquals(ControlMode.MANUAL, elevators.get(2).getMode());
		assertEquals(1, elevators.get(2).getElevatorFloor());
		assertEquals(1, elevators.get(2).getElevatorPosition());
		assertEquals(0, elevators.get(2).getCurrentTarget());
		assertEquals(DirectionType.DOWN,
			elevators.get(2).getCommittedDirection());
		assertEquals(DoorState.OPEN, elevators.get(2).getElevatorDoorStatus());
		assertEquals(0, elevators.get(2).getElevatorSpeed());
		assertEquals(5, elevators.get(2).getElevatorAccel());
		assertEquals(4, elevators.get(2).getElevatorCapacity());
		assertEquals(3, elevators.get(2).getElevatorWeight());

		assertEquals(5, elevators.get(2).getElevatorButton().length);
		assertEquals(true, elevators.get(2).getElevatorButton()[0]);
		assertEquals(false, elevators.get(2).getElevatorButton()[1]);
		assertEquals(true, elevators.get(2).getElevatorButton()[2]);
		assertEquals(true, elevators.get(2).getElevatorButton()[3]);
		assertEquals(false, elevators.get(2).getElevatorButton()[4]);

		assertEquals(5, elevators.get(2).getServicesFloors().length);
		assertEquals(true, elevators.get(2).getServicesFloors()[0]);
		assertEquals(true, elevators.get(2).getServicesFloors()[1]);
		assertEquals(true, elevators.get(2).getServicesFloors()[2]);
		assertEquals(false, elevators.get(2).getServicesFloors()[3]);
		assertEquals(false, elevators.get(2).getServicesFloors()[4]);

		ctrl.verify();
	}

	@Test
	public void testParseDataSameClockTickException() throws RemoteException,
		SameClockTickException, InvalidEnumValueException
	{
		SystemData data = new SystemData();
		data.setClockTick(100L);

		expect(mock.getClockTick()).andReturn(100L);

		ctrl.replay();

		try
		{
			adapter.parseData(data, null);

			fail("same clock tick exception expected");
		}
		catch (SameClockTickException e)
		{
			// do nothing
		}
		ctrl.verify();
	}

	@Test
	public void testParseDataException() throws RemoteException,
		SameClockTickException, InvalidEnumValueException
	{
		expect(mock.getClockTick()).andReturn(1000L);
		expect(mock.getElevatorNum()).andReturn(2);
		expect(mock.getFloorNum()).andReturn(5);
		expect(mock.getFloorHeight()).andThrow(new RemoteException());

		ctrl.replay();

		try
		{
			adapter.parseData(null, null);

			fail("remote exception expected");
		}
		catch (RemoteException e)
		{
			// do nothing
		}
		ctrl.verify();
	}

	@Test
	public void testParseDataClockClickChanged() throws RemoteException,
		SameClockTickException, InvalidEnumValueException
	{
		expectMethodsForDefaultData(200L);

		expectMethodsInitial(201L);

		expect(mock.getClockTick()).andReturn(201L);

		ctrl.replay();

		assertInitial(adapter.parseData(null, null), 201L);

		ctrl.verify();
	}

	@Test
	public void testParseDataMaxClockClickChanged() throws RemoteException,
		SameClockTickException, InvalidEnumValueException
	{
		expectMethodsForDefaultData(200L);

		expectMethodsForDefaultData(201L);

		expectMethodsInitial(202L);

		expect(mock.getClockTick()).andReturn(202L);

		ctrl.replay();

		assertInitial(adapter.parseData(null, null), 202L);

		ctrl.verify();
	}

	@Test
	public void testParseDataClockClickException() throws RemoteException,
		SameClockTickException, InvalidEnumValueException
	{
		expectMethodsForDefaultData(200L);

		expectMethodsInitial(201L);

		expectMethodsForDefaultData(202L);

		expect(mock.getClockTick()).andReturn(203L);

		ctrl.replay();

		try
		{
			adapter.parseData(null, null);

			fail("remote exception expected");
		}
		catch (RemoteException e)
		{
			assertEquals("can not get consistent state", e.getMessage());
		}

		ctrl.verify();
	}

	@Test
	public void testParseDataInvalidDoorState() throws RemoteException,
		SameClockTickException
	{
		expect(mock.getClockTick()).andReturn(1000L);
		expect(mock.getElevatorNum()).andReturn(2);
		expect(mock.getFloorNum()).andReturn(5);
		expect(mock.getFloorHeight()).andReturn(2);

		expect(mock.getFloorButtonUp(0)).andReturn(true);
		expect(mock.getFloorButtonDown(0)).andReturn(false);
		expect(mock.getFloorButtonUp(1)).andReturn(false);
		expect(mock.getFloorButtonDown(1)).andReturn(true);
		expect(mock.getFloorButtonUp(2)).andReturn(false);
		expect(mock.getFloorButtonDown(2)).andReturn(false);
		expect(mock.getFloorButtonUp(3)).andReturn(false);
		expect(mock.getFloorButtonDown(3)).andReturn(true);
		expect(mock.getFloorButtonUp(4)).andReturn(true);
		expect(mock.getFloorButtonDown(4)).andReturn(true);

		expect(mock.getElevatorFloor(0)).andReturn(2);
		expect(mock.getElevatorPosition(0)).andReturn(12);
		expect(mock.getTarget(0)).andReturn(3);
		expect(mock.getCommittedDirection(0)).andReturn(
			IElevator.ELEVATOR_DIRECTION_UP);

		//insert error
		expect(mock.getElevatorDoorStatus(0)).andReturn(
			-5);
		ctrl.replay();

		try
		{
			adapter.parseData(null, null);

			fail("invalid enum value exception expected");
		}
		catch (InvalidEnumValueException e)
		{
			// do nothing
		}
		ctrl.verify();
	}

	@Test
	public void testParseDataInvalidCommitedDirection() throws RemoteException,
		SameClockTickException
	{
		expect(mock.getClockTick()).andReturn(1000L);
		expect(mock.getElevatorNum()).andReturn(2);
		expect(mock.getFloorNum()).andReturn(5);
		expect(mock.getFloorHeight()).andReturn(2);

		expect(mock.getFloorButtonUp(0)).andReturn(true);
		expect(mock.getFloorButtonDown(0)).andReturn(false);
		expect(mock.getFloorButtonUp(1)).andReturn(false);
		expect(mock.getFloorButtonDown(1)).andReturn(true);
		expect(mock.getFloorButtonUp(2)).andReturn(false);
		expect(mock.getFloorButtonDown(2)).andReturn(false);
		expect(mock.getFloorButtonUp(3)).andReturn(false);
		expect(mock.getFloorButtonDown(3)).andReturn(true);
		expect(mock.getFloorButtonUp(4)).andReturn(true);
		expect(mock.getFloorButtonDown(4)).andReturn(true);

		expect(mock.getElevatorFloor(0)).andReturn(2);
		expect(mock.getElevatorPosition(0)).andReturn(12);
		expect(mock.getTarget(0)).andReturn(3);

		//insert error
		expect(mock.getCommittedDirection(0)).andReturn(
			-5);


		ctrl.replay();

		try
		{
			adapter.parseData(null, null);

			fail("invalid enum value exception expected");
		}
		catch (InvalidEnumValueException e)
		{
			// do nothing
		}
		ctrl.verify();
	}

	@Test
	public void testUpdateNewTarget() throws RemoteException
	{
		mock.setTarget(0, 4);
		mock.setCommittedDirection(0, IElevator.ELEVATOR_DIRECTION_UP);

		ctrl.replay();

		defaultControlElevator.setNewTarget(4);

		assertTrue(adapter.updateNewTarget(defaultElevator, defaultControlElevator));

		ctrl.verify();
	}

	@Test
	public void testUpdateNewTargetSameFloor() throws RemoteException
	{
		mock.setTarget(0, 2);
		mock.setCommittedDirection(0, IElevator.ELEVATOR_DIRECTION_UNCOMMITTED);

		ctrl.replay();

		defaultControlElevator.setNewTarget(2);

		assertTrue(adapter.updateNewTarget(defaultElevator, defaultControlElevator));

		ctrl.verify();
	}

	@Test
	public void testUpdateNewTargetDirectionUpdate() throws RemoteException
	{
		mock.setTarget(0, 2);
		mock.setCommittedDirection(0, IElevator.ELEVATOR_DIRECTION_UNCOMMITTED);

		ctrl.replay();

		defaultElevator.setCurrentTarget(2);
		defaultElevator.setCommittedDirection(DirectionType.UP);

		defaultControlElevator.setNewTarget(2);

		assertTrue(adapter.updateNewTarget(defaultElevator, defaultControlElevator));

		ctrl.verify();
	}

	@Test
	public void testUpdateNewTargetNoUpdate() throws RemoteException
	{
		ctrl.replay();

		defaultControlElevator.setNewTarget(3);

		assertTrue(adapter.updateNewTarget(defaultElevator, defaultControlElevator));

		ctrl.verify();
	}

	@Test
	public void testUpdateNewTargetNoValueSet() throws RemoteException
	{
		ctrl.replay();

		assertTrue(adapter.updateNewTarget(defaultElevator, defaultControlElevator));

		ctrl.verify();
	}

	@Test
	public void testUpdateNewTargets() throws RemoteException
	{
		mock.setTarget(0, 1);
		mock.setCommittedDirection(0, IElevator.ELEVATOR_DIRECTION_DOWN);

		ctrl.replay();

		List<ElevatorControlData> controlList = new ArrayList<ElevatorControlData>();

		ElevatorControlData controlData = new ElevatorControlData();
		controlData.setNewTarget(1);
		controlList.add(controlData);

		controlData = new ElevatorControlData();
		controlData.setNewTarget(0);
		controlList.add(controlData);

		assertFalse(adapter.updateNewTargets(defaultData, controlList));

		ctrl.verify();
	}

	@Test
	public void testUpdateNewTargetsOneOfMultipleElevators() throws RemoteException
	{
		mock.setTarget(0, 1);
		mock.setCommittedDirection(0, IElevator.ELEVATOR_DIRECTION_DOWN);

		ctrl.replay();

		List<ElevatorControlData> controlList = new ArrayList<ElevatorControlData>();

		ElevatorControlData controlData = new ElevatorControlData();
		controlData.setNewTarget(1);
		controlList.add(controlData);

		controlData = new ElevatorControlData();
		controlData.setNewTarget(1);
		controlList.add(controlData);

		assertFalse(adapter.updateNewTargets(defaultData, controlList));

		ctrl.verify();
	}

	@Test
	public void testUpdateNewTargetsOneOfMultipleElevators2() throws RemoteException
	{
		mock.setTarget(1, 3);
		mock.setCommittedDirection(1, IElevator.ELEVATOR_DIRECTION_UP);

		ctrl.replay();

		List<ElevatorControlData> controlList = new ArrayList<ElevatorControlData>();

		ElevatorControlData controlData = new ElevatorControlData();
		controlData.setNewTarget(1);
		controlList.add(controlData);

		controlData = new ElevatorControlData();
		controlData.setNewTarget(3);
		controlList.add(controlData);

		defaultData.getElevators().get(0).setElevatorDoorStatus(DoorState.CLOSED);
		defaultData.getElevators().get(1).setElevatorDoorStatus(DoorState.OPEN);

		assertFalse(adapter.updateNewTargets(defaultData, controlList));

		ctrl.verify();
	}

	@Test
	public void testUpdateNewTargetsMultipleElevatorsAll() throws RemoteException
	{
		mock.setTarget(0, 1);
		mock.setCommittedDirection(0, IElevator.ELEVATOR_DIRECTION_DOWN);

		mock.setTarget(1, 3);
		mock.setCommittedDirection(1, IElevator.ELEVATOR_DIRECTION_UP);

		ctrl.replay();

		List<ElevatorControlData> controlList = new ArrayList<ElevatorControlData>();

		ElevatorControlData controlData = new ElevatorControlData();
		controlData.setNewTarget(1);
		controlList.add(controlData);

		controlData = new ElevatorControlData();
		controlData.setNewTarget(3);
		controlList.add(controlData);

		defaultData.getElevators().get(1).setElevatorDoorStatus(DoorState.OPEN);

		assertTrue(adapter.updateNewTargets(defaultData, controlList));

		ctrl.verify();
	}

	@Test
	public void testUpdateNewTargetsException() throws RemoteException
	{
		mock.setTarget(0, 1);
		mock.setCommittedDirection(0, IElevator.ELEVATOR_DIRECTION_DOWN);
		mock.setTarget(1, 3);
		EasyMock.expectLastCall().andThrow(new RemoteException());

		ctrl.replay();

		List<ElevatorControlData> controlList = new ArrayList<ElevatorControlData>();

		ElevatorControlData controlData = new ElevatorControlData();
		controlData.setNewTarget(1);
		controlList.add(controlData);

		controlData = new ElevatorControlData();
		controlData.setNewTarget(3);
		controlList.add(controlData);

		defaultData.getElevators().get(1).setElevatorDoorStatus(DoorState.OPEN);

		try
		{
			adapter.updateNewTargets(defaultData, controlList);

			fail("remote exception expected");
		}
		catch (RemoteException e)
		{
			// do nothing
		}

		ctrl.verify();
	}

	@Test
	public void testUpdateNewTargetDirection() throws RemoteException
	{
		mock.setCommittedDirection(0, IElevator.ELEVATOR_DIRECTION_UNCOMMITTED);

		ctrl.replay();

		defaultControlElevator.setNewDirection(DirectionType.UNCOMMITTED);

		assertTrue(adapter.updateNewTarget(defaultElevator, defaultControlElevator));

		ctrl.verify();
	}

	@Test
	public void testUpdateNewTargetDirectionNoDirectionUpdate() throws RemoteException
	{
		ctrl.replay();

		defaultControlElevator.setNewDirection(DirectionType.UP);

		assertTrue(adapter.updateNewTarget(defaultElevator, defaultControlElevator));

		ctrl.verify();
	}

	@Test
	public void testUpdateNewTargetDirectionNull() throws RemoteException
	{
		ctrl.replay();

		defaultControlElevator.setNewDirection(null);

		assertTrue(adapter.updateNewTarget(defaultElevator, defaultControlElevator));

		ctrl.verify();
	}

}
